package cn.com.chengmandian.bike.service.impl;

import cn.com.chengmandian.bike.dto.FaultStationAddForm;
import cn.com.chengmandian.bike.dto.FaultStationDto;
import cn.com.chengmandian.bike.mapper.EbFaultStationMapper;
import cn.com.chengmandian.bike.model.EbFaultStation;
import cn.com.chengmandian.bike.model.vo.FaultStationVo;
import cn.com.chengmandian.bike.service.IEbFaultStationService;
import cn.com.chengmandian.core.common.constants.CommonConstant;
import cn.com.chengmandian.core.web.pojo.AgentUser;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 电单车运营-申请还车点 服务实现类
 * </p>
 *
 * @author AutoGenerator
 * @since 2021-12-23
 */
@Service
public class EbFaultStationServiceImpl extends ServiceImpl<EbFaultStationMapper, EbFaultStation> implements IEbFaultStationService {

    @Override
    public void addStation(FaultStationAddForm faultStationAddForm, AgentUser agentUser) {
        EbFaultStation faultStation = new EbFaultStation();
        faultStation.setAreaId(faultStationAddForm.getAreaId());
        faultStation.setMemberId(agentUser.getId());
        faultStation.setLng(faultStationAddForm.getLng());
        faultStation.setLat(faultStationAddForm.getLat());
        faultStation.setAddress(faultStationAddForm.getAddress());
        faultStation.setRemark(faultStationAddForm.getRemark());
        faultStation.setStatus(CommonConstant.ZERO);
        this.save(faultStation);
    }

    @Override
    public IPage<FaultStationVo> getPage(FaultStationDto dto,Integer memberId) {
        Page page = Page.of(dto.getPageNumber(), dto.getPageSize());
        return baseMapper.getPage(page, dto,memberId);
    }
}
